package Service;

import Dao.UserDao;
import Pojo.User;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class UserService {
    private UserDao userDao = new UserDao();

    public User getUserByTelephoneAndPassword(String telephone, String password) throws SQLException {
        return userDao.getUserByTelephoneAndPassword(telephone, password);
    }

    public int getUserCountByTelOrEmail(String tel, String email) throws SQLException {
        return userDao.getUserCountByTelOrEmail(tel, email);
    }

    public int insertUser(String tel, String password, String nickname, String email, String username) throws SQLException {
        return userDao.insertUser(tel, password, nickname, email, username);
    }

    public int updatePasswordByUserId(int userId, String password) throws SQLException {
        return userDao.updatePasswordByUserId(userId, password);
    }

    public int updateUserMsgByUserId(String nickname, String email, String username, int userId) throws SQLException {
        return userDao.updateUserMsgByUserId(nickname, email, username, userId);
    }

    public List<Map<String, Object>> getUsersIsAdminBySelective(int searchCon, String search, int pageIndex) throws SQLException {
        return userDao.getUsersIsAdminBySelective(searchCon, search, pageIndex);
    }

    public int getUsersCountIsAdminBySelective(int searchCon, String search) throws SQLException {
        return userDao.getUsersCountIsAdminBySelective(searchCon, search);
    }

    public int deleteUserIsAdminByUserId(String userId) throws SQLException {
        return userDao.deleteUserIsAdminByUserId(userId);
    }
}
